import json as js

import requests as rq

from common.LogCommon import log


class RequestUtil(object):
    @log("get请求")
    def get(url=None):
        query_handler = rq.get(url)
        res_context = query_handler.text
        query_handler.close()
        return res_context

    @log("post请求")
    def query(url=None, *args, **kwargs):
        query_handler = rq.post(url, json=js.dumps(kwargs))
        res_context = query_handler.text
        query_handler.close()
        return res_context
